<template>
  <div class="comment" v-if="this.comment">
    <UserHeader
      :photo="this.comment.u.p"
      :name="this.comment.u.n"
      :lvl="this.comment.u.lvl"
    >
      <div class="user-icon">
        <van-icon name="like-o" /><span>{{ this.comment.like_count }}</span>
      </div>
    </UserHeader>
    <div class="comment-content">
      {{ this.comment.content[0]?.c }}
    </div>
    <div class="reply">
      <div
        class="reply-item"
        v-for="item in this.comment.child_comments"
        :key="item.id"
      >
        <span class="name"
          >{{ item.u.n }} <span v-if="item.id == author.user_id">(作者)</span> :
        </span>
        <span class="reply-text">
          <span v-if="item.reply_user">回复</span
          ><span v-if="item.reply_user" class="name">{{
            item.reply_user.n
          }} : </span
          >{{ item.content[0].c }}
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import UserHeader from "@/components/UserHeader.vue";
export default {
  components: {
    UserHeader,
  },
  props: ["comment", "author"],
  created() {
    // console.log(this.comment);
    // console.log(this.author);
  },
};
</script>

<style lang="scss" scoped>
.comment {
  color: var(--text-gray4);
  font-size: 0.14rem;
  .user-icon {
    font-size: 0.13rem;
    margin-right: 0;
    margin-left: auto;
  }
  .comment-content {
    padding: 0.1rem 0;
  }
  .reply {
    width: 100%;
    background-color: var(--bgc-gray2);
    border-radius: 0.12rem;
    font-size: 0.15rem;
    color: var(--text-black);
    .reply-item {
      width: 100%;
      box-sizing: border-box;
      padding: 0.1rem;
      .name {
        font-weight: bold;
        color: var(--text-black);
      }
      .reply-text {
        color: var(--text-gray4);
      }
    }
  }
}
</style>